<?php

if(!isset($_SESSION)) session_start();
if (!isset($_SESSION['f_user_id'])) {
	echo 'Access denied!';
} else {

	$form = f()->form('add_appraisal','New Appraisal')
		->hidden('student_id',$param)
		->text('name',t('Name'))
		->text('value',t('Value'))
		->image('image',t('Image'))
		->text('comment',t('Comment'),array(
			'rows' => 3,
		))
		->button('submit',t('Create'));
	
	if ($form->submitted()) {
		$fields = array('name','value','image','comment','student_id');
		$o = $this->db()->create('appraisal','Appraisal');
		$form->load();
		$form->save($o,$fields);
		$o->date = date('Y-m-d');
		$o->save();
		$student = f()->db()->find_by_pkey('student','Student',$o->student_id);
		$this->redirect('@classroom/'.$student->classroom_id);
	} else {
		$form->render();
	}

}